import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Vant from 'vant'
import 'vant/lib/index.css'
Vue.config.productionTip = false
import './assets/font/iconfont.css'
import 'amfe-flexible'
import vueEsign from 'vue-esign'
import preview from 'vue-photo-preview'
import echarts from 'echarts'
import 'vue-photo-preview/dist/skin.css'
Vue.use(Vant)
import {VueJsonp} from 'vue-jsonp'
Vue.use(VueJsonp)
Vue.use(preview)
Vue.use(vueEsign)

Vue.prototype.$echarts = echarts

import { Toast } from 'vant'
Vue.use(Toast)
import { Lazyload } from 'vant'
Vue.use(Lazyload);
import lrz from "lrz";
Vue.prototype.$lrz = lrz

import moment from 'moment'

Vue.prototype.$moment = moment;
// import Vconsole from 'vconsole'
// const vConsole = new Vconsole();


window.sid =parent.sid;
// alert(window.sid)
// window.sid='c0648c32-67ba-424e-bb5f-b61d2f31cf32';
// sessionStorage.setItem('sid', window.sid );



// function loadPageVar (sVar) {npm install echarts@4.7.0 --save
//   return decodeURI(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + encodeURI(sVar).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
// }
//  console.log('路由URL参数sid：' + loadPageVar("sid"))
// // console.log(parent.sid,"++++parent.sid")
// window.sid =loadPageVar("sid");
Vue.prototype.$sid=window.sid;
const setHtmlFontSize = () => {
  const htmlDom = document.getElementsByTagName('html')[0];
  let htmlWidth = document.documentElement.clientWidth || document.body.clientWidth;
  console.log(htmlWidth,"+++htmlWidth")
  if(htmlWidth>750){
    htmlWidth = 980
  }
  if(htmlWidth<=980){
    console.log(htmlWidth)
  }
  htmlDom.style.fontSize = `${htmlWidth / 40}px`;
};
window.onresize = setHtmlFontSize;
setHtmlFontSize()

router.beforeEach((to, from, next) => {
  // console.log(to,'to');
  if(to.query && to.query.sid){
    window.sid =to.query.sid
    Vue.prototype.$sid=window.sid;
  }/* else{
    //session过期直接跳转，防止报错； window.location.href=`${window.location.host}/portal`;
    window.location.href='http://10.213.120.206/portal';return;//todo change window.location.host
  } */
  next();
});
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
